<template>
  <tui-modal
    title="提示"
    :show="show"
    :mask-closable="false"
    :content="phone+'账号正在注销审核中，是否取消注销？'"
    :button="buttons"
    @click="onclick"
  />
</template>

<script>
import { mapGetters } from 'vuex'
import { withdrawCancelByUserId } from '../../api'
export default {
  name: 'LogOutDialog',
  props: {
    show: {
      type: Boolean,
      default: false
    },
    phone: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      buttons: [
        {
          text: '等待审核',
          type: 'gray'
        },
        {
          text: '确定取消'
        }
      ]
    }
  },
  computed: {
    ...mapGetters({
      userId: 'userId'
    })
  },
  methods: {
    onclick(e) {
      const inx = e.index
      if (inx) {
        this.confirm()
      } else {
        this.cancel()
      }
    },
    async confirm() {
      this.cancel()
      const [err, res] = await withdrawCancelByUserId({ userId: this.userId })
      if (!this.$http.errorCheck(err, res)) return false
      this.$emit('confirm')
    },
    cancel() {
      this.$emit('update:show', false)
    }
  }
}
</script>

<style scoped>

</style>
